<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
    <title>悦章科技机构平台</title>
    <script src="/Public/static/jquery-2.0.3.min.js"></script>
    <script src="/Public/static/layer/layer.js"></script>
    <!--内容样式-->
    <link rel="stylesheet" href="__PUBLIC__/Home/css/style.css" />
    <link rel="stylesheet" href="__PUBLIC__/Home/css/page.css" />
</head>
<body>

<div class="main">
    <!--  头部  -->
    <include file="menu" />

    <!--  右侧内容  -->
    <div class="content">
        <div class= "ct-title">
            <div class="ctt-bt">班级列表</div>
            <div class="ctt-r">
                <form class="cttr-bd" action="{:U('Home/Educational/classList')}" method="post">
                    <input type="text" placeholder="请输入班级名称" class="cttrb-wb" name="name" value="{$name}">
                    <select class="cttrb-xl" name="one_class_id">
                        <option value="">一级分类</option>
                        <volist name="parent" id="vo">
                            <option value="{$vo.id}" <if condition="$one_class_id eq $vo['id']">selected</if>>{$vo.name}</option>
                        </volist>
                    </select>
                    <select class="cttrb-xl" name="two_class_id">
                        <option value="">二级分类</option>
                        <volist name="child" id="vo">
                            <option value="{$vo.id}" <if condition="$two_class_id eq $vo['id']">selected</if>>{$vo.name}</option>
                        </volist>
                    </select>
                    <select class="cttrb-xl" name="status">
                        <option value="">班级状态</option>
                        <option value="1" <if condition="$status eq 1">selected</if>>应届</option>
                        <option value="2" <if condition="$status eq 2">selected</if>>往届</option>
                    </select>
                    <button class="cttrb-cx">查询</button>
                    <a href="{:U('Home/Educational/saveClass')}" class="cttrb-xz">新增班级</a>
                    <div class="divclear"></div>
                </form>
                <div class="divclear"></div>
            </div>
            <div class="divclear"></div>
        </div>

        <div class="ct-table">
            <table width="100%" border="0">
                <tbody>
                <tr>
                    <th scope="col" width="15%" style="border-top-left-radius: 10px;">班级名称</th>
                    <th scope="col" width="15%">班级一级分类</th>
                    <th scope="col" width="15%">班级二级分类</th>
                    <th scope="col" width="10%">班级状态</th>
                    <th scope="col" width="10%">学生人数</th>
                    <th scope="col" width="20%">起止日期</th>
                    <th scope="col" width="15%" style="border-top-right-radius: 10px;">操作</th>
                </tr>
                <volist name="_list" id="vo">
                    <tr>
                        <td>{$vo.name}</td>
                        <td>{$vo.parent}</td>
                        <td>{$vo.child}</td>
                        <td><if condition="$vo['status'] eq 1">应届<else/>往届</if></td>
                        <td>{$vo.count}</td>
                        <td>{$vo.start_time|date='Y-m-d',###} ~ {$vo.end_time|date='Y-m-d',###}</td>
                        <td>
                            <a href="{:U('Home/Educational/studentList')}">学生管理</a>
                            <a href="{:U('Home/Educational/saveClass',array('id'=>$vo['id']))}">编辑</a>
                            <a href="{:U('Home/Educational/delClass',array('id'=>$vo['id']))}">删除</a>
                        </td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>
        <div class="page">
            {$_page}
        </div>
        <!--<div class="ct-btn">
            <div class="ctb-an"><</div>
            <div class="ctb-an ctb-an-on">1</div>
            <div class="ctb-an">2</div>
            <div class="ctb-an">3</div>
            <div class="ctb-an">></div>
            <div class="divclear"></div>
        </div>-->
    </div>
</div>
</body>
<script type="text/javascript">
    $("select[name='one_class_id']").change(function(){
        var cc_id = $(this).val();
        var url = "{:U('Home/Educational/getTwoClass')}";
        $.ajax({
            type: "POST", //类型get，post
            url: url, //链接地址
            data:{"cc_id":cc_id},//参数，一般post用
            success: function(data){
                var dataObj = JSON.parse(data);
                $("select[name='two_class_id']").empty();
                $("select[name='two_class_id']").append("<option value=''>二级分类</option>");
                //成功后函数
                if(dataObj.result == 1){
                    for(var i=0;i<dataObj.data.length;i++){
                        $("select[name='two_class_id']").append("<option value='"+dataObj.data[i]['id']+"'>"+dataObj.data[i]['name']+"</option>");
                    }
                }
            },
            error:function(){
                //失败时函数
                layer.msg("失败");
            }
        })
    })
</script>
</html>
